package edu.duixiang;

public class personDemo {
    public static void main(String[] args) {
        person p = new person();              //无参构造的new
        System.out.println("姓名：" + p.name + "  年龄:" + p.age);

        person p1 = new person(18);            //构造方法的重载只需新建一个new即可(单参)
        person p2 = new person("小明", 18);
        p.method();

        Student student = new Student();
        System.out.println("姓名： " + student.name + "  年龄： " + student.age);

        Student student1 = new Student("小胡", 19);//两个学生信息进行比较
        System.out.println(student1.compare(student));

        Student a=new Student("小李",10);
        Student b=new Student("小张",12);
        swap(a,b);
        System.out.println(a.age+" "+b.age);
    }


    public static void swap(Student x,Student y){    //使用对象储存在堆里进行变量交换；
        int temp=x.age;
        x.age=y.age;
        y.age=temp;
    }
}
